package com.zking.service.impl;

import com.zking.entity.Chima;
import com.zking.entity.Guige;
import com.zking.entity.Product;
import com.zking.entity.Yanse;
import com.zking.mapper.GuigeMapper;
import com.zking.mapper.ProductMapper;
import com.zking.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@Transactional
public class ProductServiceImpl extends BaseServiceImpl<Product> implements ProductService {

    @Autowired
    ProductMapper productMapper;
    @Autowired
    GuigeMapper guigeMapper;


    @Override
    public Map<String, Object> initProduct(int spid) {
        Map<String,Object> map = new HashMap<>();
        // 查询商品
        Product product = productMapper.selectByPrimaryKey(spid);
        map.put("product",product);
        // 查询颜色
        List<Yanse> yanse = productMapper.getYanse(spid);
        map.put("yanses",yanse);
        // 查询尺码
        List<Chima> chima = productMapper.getChima(spid);
        map.put("chimas",chima);
        // 查询规格
        Guige guige = new Guige();
        guige.setSpid(spid);
        map.put("guiges",guigeMapper.select(guige));
        return map;
    }
}
